package com.valley.dream.birds.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Valley
 * Created by Valley on 2022/7/6
 */

public class DateUtil {

    public static String dateToStr(Date date){
        if (date == null) return "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
        return sdf.format(date);
    }

    public static Date strToDate(String string){
        if (string == null) return null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
        Date parse = null;
        try {
            parse = sdf.parse(string);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}
